package com.clqteam.daoimpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.clqteam.dao.InitDao;
import com.clqteam.util.JDBCutil;

public class InitDaoImpl implements InitDao{

	@Override
	public void deleteDailyByDate(String date) {
		StringBuffer sql = new StringBuffer();
		sql.append("DELETE FROM s_dailyreport WHERE s_dailyreport.drTime < ?");
		Connection con = JDBCutil.getConnection();
		try {
			PreparedStatement pst = con.prepareStatement(sql.toString());
			pst.setString(1, date);
			pst.executeUpdate();
			JDBCutil.closeJDBC(pst, con);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
		
	}

	@Override
	public void deleteOrderByDate(String date) {
		StringBuffer sql = new StringBuffer();
		sql.append("DELETE FROM s_order WHERE s_order.oTime< ?");
		Connection con = JDBCutil.getConnection();
		try {
			PreparedStatement pst = con.prepareStatement(sql.toString());
			pst.setString(1, date);
			pst.executeUpdate();
			JDBCutil.closeJDBC(pst, con);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
	}

}
